<template>
    <div>
        日期
        <el-date-picker v-model="form.DateTime" type="datetimerange" start-placeholder="开始时间" end-placeholder="结束时间"
            format="YYYY-MM-DD  " />&emsp;&emsp;
        <el-button type="primary" @click="getreportList">查询</el-button>
    </div>
    <div style="height: 300px;">
        <iframe :src=reportUrl frameborder="0" width="100%" height="100%"></iframe>

    </div>
</template>
<script lang="ts" setup>
import { Check, Delete, Plus, Back } from '@element-plus/icons-vue';
import { reactive, ref, onMounted } from 'vue';
import axios from 'axios';
import { useRoute, useRouter } from 'vue-router';
import { ElMessage, ElMessageBox } from 'element-plus';
//调用持久化
import { useCounterStore } from '@/stores/counter';
const counterStore = useCounterStore();
const route = useRoute();
const router = useRouter();
const reportUrl = ref('http://localhost:8075/webroot');
const form = reactive({
    DateTime: [new Date(), new Date()],
    sleepTypeId: '',
    type: '',
    typeId: '',
    type2Id: '',
    summaryType: '',
})

onMounted(() => {
    getreportList()
})

const getreportList = () => {

    let minDate1 = form.DateTime[0];
    let maxDate1 = form.DateTime[1];
    let maxYear = minDate1.getFullYear();
    let maxMonth = (minDate1.getMonth() + 1).toString().padStart(2, '0');
    let maxDay = minDate1.getDate().toString().padStart(2, '0');


    let maxYear2 = maxDate1.getFullYear();
    let maxMonth2 = (maxDate1.getMonth() + 1).toString().padStart(2, '0');
    let maxDay2 = maxDate1.getDate().toString().padStart(2, '0');
    let minDate = `${maxYear}-${maxMonth}-${maxDay}`;
    let maxDate = `${maxYear2}-${maxMonth2}-${maxDay2}`;
    reportUrl.value = reportUrl.value + "/decision/view/report?viewlet=WorkBook2.cpt?" + '&MinDate=' + minDate
        + '&MaxDate=' + maxDate + `&SleepTypeId=0&Type=0&TypeId=0&Type2Id=0&SummaryType=0`;
    console.log(reportUrl.value);
}



</script>